"""
#!/usr/bin/python3
# coding:utf-8            
#
# Copyright (C) 2024 - 2024 Jasonakeke， Inc. All Rights Reserved 
# @Desc	   ：
# @Time    : 2024/8/4 21:22
# @Author  : Code_By_Jasonakeke
# @Email   : 2284037977@qq.com
# @File    : 07自定义转换器.py
# @IDE     : PyCharm
"""
from flask import Flask, url_for, redirect
from werkzeug.routing import BaseConverter

"""
自定义转换器
"""


class MobileConverter(BaseConverter):
	regex = r'1[3-9]\d{9}'

	def to_python(self, value):
		return value

	def to_url(self, value):
		return value


app = Flask(__name__)
app.url_map.converters['phone'] = MobileConverter

@app.route('/')
def helloworld():
	print(url_for('phone_num', mob_num = '18900998877'))
	print(url_for('phone_num', mob_num = '18900998877', page = 2))
	return redirect(url_for('phone_num', mob_num = '18900998877'))


@app.route('/phone/<mob_num>')
def phone_num(mob_num):
	return '当前访问的手机号码是：{}'.format(mob_num)


if __name__ == '__main__':
	app.run(debug = True)
